// pages/classify/classify.js
Page({
  data: {
    classifyLift:[
			{
				nav:'热门',
				active:true,
				sec:['家常','烘焙类','素菜','凉菜','早餐','下饭','川菜','面食','东北菜','晚餐','其他蛋糕','烤箱','粤菜','寿司','汤羹','湘菜','西餐','私房菜','面包','披萨','饼','糕点','炒饭','砂锅','清淡','馒头','电饼铛','鲁菜','饺子','孕妇食谱','微波炉','炒面','岁宝宝','拌面','电炖锅','汤圆','电饭煲','油条','饼干','淮扬菜','荤菜','家常味','豆浆','产妇食谱','零食','闽菜','咖喱','布丁','浙菜','清真','水产海鲜','春节']
			},
			{
				nav:'精选',
				active:false,
				sec:['烘焙类','家常味','川菜类','凉菜类','创意类','热门菜','湘菜类','素类','粤菜类','肉类','西餐类','鲁菜类','女王菜','美容养颜','鱼类','小资系','面点','京味菜','靓汤','海鲜类']
			},
			{
				nav:'肉类',
				active:false,
				sec:['猪肉','排骨','猪蹄','猪肚','五花肉','猪肝','猪血','猪腰','猪皮','猪肘','猪耳朵','猪心','猪肺','猪大肠','猪大骨头','猪小排','猪里脊肉','猪脑','猪排','猪舌头','猪脑袋','牛肉','牛腩','牛排','肥牛','牛肚','牛蹄筋','牛尾','牛肺','牛肾','牛鞭','羊肉','羊排','羊肝','羊肚','羊蝎子','羊肾']
			},
			{
				nav:'蛋/奶',
				active:false,
				sec:['家常','烘焙类']
			},
			{
				nav:'鱼类',
				active:false,
				sec:['家常','烘焙类']
			},
			{
        nav:'水产',
        active:false,
        sec:['家常','烘焙类']
			},
			{
				nav:'蔬菜',
				active:false,
				sec:['家常','烘焙类']
			},
			{	
        nav:'豆类',
        active:false,
        sec:['家常','烘焙类']
			},
			{
				nav:'果品类',
				active:false,
				sec:['家常','烘焙类']
			},
			{
				nav:'五谷杂粮',
				active:false,
				sec:['家常','烘焙类']
			},
			{
				nav:'药食',
				active:false,
				sec:['家常','烘焙类']
			},
			{
				nav:'调味品',
				active:false,
				sec:['家常','烘焙类']
			},
			{
				nav:'其他',
				active:false,
				sec:['家常','烘焙类']
			},
			{
				nav:'菜式',
				active:false,
				sec:['家常','烘焙类']
			},
			{
				nav:'菜系',
				active:false,
				sec:['家常','烘焙类']
			},
			{
				nav:'烘焙',
				active:false,
				sec:['家常','烘焙类']
			},
			{
				nav:'主食',
				active:false,
				sec:['家常','烘焙类']
			},
			{
				nav:'器具',
				active:false,
				sec:['家常','烘焙类']
			},
			{
				nav:'烹饪方式',
				active:false,
				sec:['家常','烘焙类']
			},
			{
				nav:'口味',
				active:false,
				sec:['家常','烘焙类']
			},
			{
				nav:'场合',
				active:false,
				sec:['家常','烘焙类']
			}
		],
		classifyRight:[
			'家常','烘焙类','素菜','凉菜','早餐','下饭','川菜','面食','东北菜','晚餐','其他蛋糕','烤箱','粤菜','寿司','汤羹','湘菜','西餐','私房菜','面包','披萨','饼','糕点','炒饭','砂锅','清淡','馒头','电饼铛','鲁菜','饺子','孕妇食谱','微波炉','炒面','岁宝宝','拌面','电炖锅','汤圆','电饭煲','油条','饼干','淮扬菜','荤菜','家常味','豆浆','产妇食谱','零食','闽菜','咖喱','布丁','浙菜','清真','水产海鲜','春节','烘焙类','家常味','川菜类','凉菜类','创意类','热门菜','湘菜类','素类','粤菜类','肉类','西餐类','鲁菜类','女王菜','美容养颜','鱼类','小资系','面点','京味菜','靓汤','海鲜类','猪肉','排骨','猪蹄','猪肚','五花肉','猪肝','猪血','猪腰','猪皮','猪肘','猪耳朵','猪心','猪肺','猪大肠','猪大骨头','猪小排','猪里脊肉','猪脑','猪排','猪舌头','猪脑袋','牛肉','牛腩','牛排','肥牛','牛肚','牛蹄筋','牛尾','牛肺','牛肾','牛鞭','羊肉','羊排','羊肝','羊肚','羊蝎子','羊肾'
		]
  },
  // 点击搜索框跳转到搜索详情页
  ToSearchDetails(){
    wx.navigateTo({
      // 注意不要加后缀名.wxml
      url: '../SearchDetails/SearchDetails',
    })
  },
  // 点击左边分类词渲染右边逻辑
  addActive(e){
    //小程序在组件上绑定事件后，传递参数的方式不同于前端开发其他场景中直接加参数的方式，小程序在参数的传递时，采用事件对象的自定义属性的方式
    let index = e.currentTarget.dataset['suo'];
    // console.log(index);//当前点击项的索引
    //把点击的这项设为当前项，active的值为true，反之为false
    this.data.classifyLift.forEach((item,i)=>{
      item.active=(index===i)
    })
    //把修改后的数据重新赋值给classifyList当前项的内容赋值给右边的数据claRight 这种方式设置的数据修改，页面才能同步修改
    this.setData({
      classifyLift:this.data.classifyLift,
      classifyRight:this.data.classifyLift[index].sec
    })
  }
})